package com.yanqu.road.server.cmd.guess;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CommonGuessProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.guess.CrossCommonGuessMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C2_COMMON_GUESS_REWARD_COMPLETE_USER, desc = "通用竞猜-获取竞猜中奖档位玩家LIST")
public class CrossCommonGuessGetRewardCompleteUserListCmd extends CrossCommand {

    private long playerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        playerId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CommonGuessProto.CommonGuessRewardCompleteUserReqMsg reqMsg = CommonGuessProto.CommonGuessRewardCompleteUserReqMsg.parseFrom(packet.getBytes());
        CommonGuessProto.CommonGuessRewardCompleteUserRespMsg.Builder respMsg;
        try {
            respMsg = CrossCommonGuessMgr.getRewardCompleteUserList(packet.getPlayerId(), 0, reqMsg);
        } catch (BusinessException e) {
            respMsg = CommonGuessProto.CommonGuessRewardCompleteUserRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
        }
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_COMMON_GUESS_REWARD_COMPLETE_USER, respMsg));
    }

    @Override
    public void sendData() {

    }
}
